﻿using System.Security.Cryptography;
using System.Text;
using System.IO;
using System;

class EncryptionWithStreams
{
    public static string GenerateHash(string filePathAndName)
    {
        string hashText = "";
        string hexValue = "";

        byte[] fileData = File.ReadAllBytes(filePathAndName);
        byte[] hashData = SHA1.Create().ComputeHash(fileData); // SHA1 or MD5

        foreach (byte b in hashData)
        {
            hexValue = b.ToString("X").ToLower(); // Lowercase for compatibility on case-sensitive systems
            hashText += (hexValue.Length == 1 ? "0" : "") + hexValue;
        }

        return hashText;
    }

    public static void CreateBinaryFile(string fileName)
    {
        using (StreamWriter writer = new StreamWriter(fileName))
        {
            writer.Write(1);
        }
    }

    static void Main(string[] args)
    {
        string fileName = "..\\..\\file.bin";
        //CreateBinaryFile(fileName);
        string SHA1 = GenerateHash(fileName);
        Console.WriteLine(SHA1);
    }
}